/*
createRouter:用来创建router实例对象 new Router();
createWebHashHistory:路由模式变化,vue3方法形式
*/
import { createRouter, createWebHashHistory } from 'vue-router'
import login from '@/views/Login'
import layout from '@/views/Layout'
import category from '@/views/Category'
import home from '@/views/Home'
import good from '@/views/Good'
import cart from '@/views/cart'
import settlement from '@/views/settlement/index.vue'
import pay from '@/views/pay/index.vue'
import callBack from '@/views/pay/callBack.vue'

const routes = [
  { path: '/login', component: login },
  {
    path: '/',
    component: layout,
    // path置空,将作为默认的二级路由显示
    children: [
      { path: '', component: home },
      { path: 'category/:id', component: category },
      { path: 'good/:id', component: good },
      // 购物车支付列表
      { path: 'cart', component: cart },
      { path: 'settle', component: settlement },
      { path: 'pay/:id', component: pay },
      { path: 'pay/callback', component: callBack }
    ]
  }
]

// 创建路由实例对象  导出给main.js使用
const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
